<template>
  <div style="text-align:center" v-if="flag">
    <img :src="data.jktjxdtbglj" style="height:1020px;width:710px" alt=""> &nbsp;
  </div>
  <div v-else>
    <table style="margin-left: auto; margin-right: auto;text-align:left">
      <tbody>
        <br/>
        <tr style="height: 25px">
          <td style="height: 25px;text-align:center" colspan="5" width="710">
            <h1>{{jkdn.jddw}}</h1>
            <p style="height:25px;margin-top:25px;margin-bottom:25px;font-size:32px">
              <strong>超声医学影像报告单</strong>
            </p>
          </td>
        </tr>
        <tr style="height: 25px;border-bottom:2px solid black;margin-bottom:5px">
          <td style="height: 25px;" width="150" colspan="4">
            <p>检查部位: 腹部B超</p>
          </td>
          <td style="height: 25px;" width="150" colspan="1">
            <p>超声号:{{data.tmcode}}</p>
          </td>
        </tr>
        <tr style="height: 30px;">
          <td style="height: 30px;" width="150">
            <p>姓名：{{jkdn.name}}</p>
          </td>
          <td style="height: 30px;" width="150">
            <p>性别: {{sex==1?'男':'女'}}</p>
          </td>
          <td style="height: 30px;" width="150">
            <p>年龄: {{jkdn.age}}</p>
          </td>
          <td style="height: 30px;" width="150">
            <p>初诊:</p>
          </td>
          <td style="height: 30px;" width="150">
            <p>科别：</p>
          </td>
        </tr>
        <tr style="height: 30px; border-bottom:2px solid black;margin-bottom:5px">
          <td style="height: 30px;" width="150">
            <p>检查号：</p>
          </td>
          <td style="height: 30px;" width="150">
            <p>病历号:</p>
          </td>
          <td style="height: 30px;" width="150">
            <p>住院号:</p>
          </td>
          <td style="height: 30px;" width="150">
            <p>病区号:</p>
          </td>
          <td style="height: 30px;" width="150">
            <p>床位号:</p>
          </td>
        </tr>

        <tr style="height: 25px;border-bottom:2px solid black;margin-bottom:5px">
          <td colspan="5" width="300" style="text-align:center">
            <div v-for="item in imgs" :key="item.id" style='display:inline'>
              <img :src="item" style="height:230px;width:370px;margin-top:10px" alt=" "> &nbsp;
            </div>

          </td>
        </tr>
        <tr style="height: 25px ">
          <td colspan="5 " width="300 " style="text-align:left; ">
            <p>超声所见:</p>
          </td>
        </tr>
        <tr style="height: 25px ;border-bottom:2px solid black;margin-bottom:5px ">
          <td colspan="45 " width="300 " height="200" style="text-align:left; " contenteditable="true">
            <p id="cssj" v-html="cssj">
            </p>
          </td>
        </tr>
        <tr style="height: 25px ">
          <td colspan="5" style="text-align:left; ">
            <p>诊断意见:</p>
          </td>
        </tr>
        <tr style="height: 25px ;border-bottom:2px solid black;margin-bottom:5px ">
          <td colspan="45 " width="300" height="100" style="text-align:left; " contenteditable="true">
            <p v-html="zdyj" id="zdyj">
            </p>
          </td>
        </tr>
        <tr style="height: 25px ;border-bottom:2px solid black;margin-bottom:5px ">
          <td colspan="5" height="150 " style="text-align:left; ">
            <p>
            </p>
          </td>
        </tr>
        <tr style="height: 25px ;">
          <td colspan="3" width="300" style="text-align:left;padding-top:5px">
            <p></p>
          </td>
          <td width="200" style="text-align:left;padding-top:5px">
            <p>申请医师: </p>
          </td>
          <td width="200" style="text-align:left;padding-top:5px">
            <p>诊断医师:{{jgxx.bchaory}} </p>
          </td>
        </tr>
        <tr style="height: 25px ">
          <td colspan="3" style="text-align:left; ">
          </td>
          <td colspan="2" style="text-align:left ">
            <p>检查时间：{{jkdn.jdrq}}</p>
          </td>
        </tr>
        <tr style="text-align:center; ">
          <td colspan="5">
            <p style="font-size: 12px;padding-top:50px">只作临床参考，不作证明材料</p>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>
<script>
import { getObj, updateObj } from '@/api/cust/health/color'
import { getStore } from '@/util/store.js'
export default {
  name: 'xcgct',
  data() {
    return {
      grjbxxid: '',
      jktjid: '',
      sfzh: '',
      tmcode: '',
      data: {},
      jkdn: '',
      flag: false,
      sex: '',
      imgs: [],
      cssj: '',
      zdyj: '',
      jgxx: ''
    }
  },
  created() {
    this.jgxx = getStore({ name: 'org' })
    this.jkdn = getStore({ name: 'jkdn' })
    this.sex = parseInt(this.jkdn.sfzhm.substr(16, 1)) % 2
    this.grjbxxid = this.$route.query.grjbxxid
    this.jktjid = this.$route.query.id
    this.sfzh = this.$route.query.sfzh
    this.tmcode = this.$route.query.tmcode
    this.getObj()
  },
  mounted() {},
  methods: {
    handleHtmlcssj($event) {
      console.log(1)
      setTimeout(() => {
        this.data.jktjcsts = $event.target.innerHTML
      }, 100)
      // text.replace('/<p>/g', '').replace('/</p>/g', '')
    },
    handleHtmlzdyj($event) {
      this.data.jktjcsms = $event.target.innerHTML
    },
    save() {
      this.data.jktjcsts = document.getElementById('cssj').innerHTML
      this.data.jktjcsms = document.getElementById('zdyj').innerHTML
      updateObj(this.data).then(() => {
        this.$message({
          message: '保存成功',
          type: 'success'
        })
      })
    },
    getObj() {
      getObj({
        tmcode: this.tmcode
      }).then(res => {
        this.data = res.data.data
        this.cssj = res.data.data.jktjcsts
        this.zdyj = res.data.data.jktjcsms
        if (
          !this.validatenull(this.data) &&
          !this.validatenull(this.data.repjpgbase64)
        ) {
          this.flag = true
          this.imgs.push('data:image/png;base64,' + this.data.repjpgbase64)
        } else {
          //this.data = {}
          if (!this.validatenull(this.data.jktjbglj)) {
            this.imgs.push('/api/statics/' + this.data.jktjbglj)
          }
          if (!this.validatenull(this.data.jktjtplj)) {
            this.imgs.push('/api/statics/' + this.data.jktjtplj)
          }
        }
      })
    }
  },
  computed: {},
  props: []
}
</script>
<style>
td {
  padding-left: 10px;
  padding-top: 5px;
}
p {
  font-size: 18px;
}
</style>
